vtypes = ['int', 'flt', 'str']
stypes = ['GAUGE', 'COUNTER', 'DERIVE', 'ABSOLUT']
draws = ['LINE1', 'LINE2', 'LINE3', 'AREA', 'STACK']
SPROTOCOLS = ['tcp', 'irc']
NPROTOCOLS = ['tcp', 'irc', 'snmp']

class Group(object):
    pass

class User(object):
    pass

class Node(object):
    def by_name(self, cls, nodename):
        return cls.query(self).filter_by(name = unicode(nodename)).first()
    by_name = classmethod(by_name)
    
    def by_id(self, cls, nodeid):
        return cls.query(self).filter_by(node_id = nodeid).first()
    by_id = classmethod(by_id)

class Server(object):
    def by_id(self, cls, serverid):
        return cls.query(self).filter_by(server_id = serverid).first()
    by_id = classmethod(by_id)
    
    def by_name(self, cls, servername):
        return cls.query(self).filter_by(name = unicode(servername)).first()
    by_name = classmethod(by_name)

class Item(object):
    def by_plug_and_name(self, cls, plugid, iname):
        return cls.query(self).filter_by(plugin_id =\
                            plugid).filter_by(name = unicode(iname)).first()
    by_plug_and_name = classmethod(by_plug_and_name)

class Plugin(object):
    def by_node_and_plug(self, cls, nodeid, plugname):
        return cls.query(self).filter_by(name =\
                        unicode(plugname)).filter_by(node_id = nodeid).first()
    by_node_and_plug = classmethod(by_node_and_plug)
    
    def by_id(self, cls, plugid):
        return cls.query(self).filter_by(plugin_id = plugid).first()
    by_id = classmethod(by_id)
  
    """
class Action(object):
    def by_item(self, cls, itemid):
        return cls.query(self).filter_by(item_id = itemid).first()
    by_item = classmethod(by_item)
"""

class Action(object):
    pass

class Event(object):
    def by_itm_and_type(self, cls, itemid, evt_type):
        return cls.query(self).filter_by(item_id = itemid).filter_by(\
                                              event_type = evt_type).first()
    by_itm_and_type = classmethod(by_itm_and_type)

class Value(object):
    def by_item_and_time(self, cls, itemid, timestmp):
#        return cls.query(self).filter_by(item_id = itemid).filter_by(\
 #                                             timestamp = timestmp).first()
        return None
    by_item_and_time = classmethod(by_item_and_time)

